package thread.Threadlocal;

public class ThreadLocalDemo extends Thread {

	public static void main(String[]args) {
		Thread threadOne = new ThreadLocalDemo();
		threadOne.start();

		Thread threadTwo = new ThreadLocalDemo();
		threadTwo.start();
	}

	public void run() {
		Context context = new Context();
		context.setTransactionId(Thread.currentThread().getName());
		// set the context object in thread local to access it somewhere else
		MyThreadLocal.set(context);
		new BusinessService().businessMethod();
		MyThreadLocal.unset();
	}

}
/*
 * As you might see, even though we are not explicitly passing the transaction id, 
 * the value can be accessed from the business method and printed on the console
Thread-1
Thread-0

 * */
 